package com.ruoyi.hospital.controller;


import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.hospital.entity.LoginHospital;
import com.ruoyi.hospital.service.HospitalCheckService;
import com.ruoyi.hospital.service.HospitalOrderService;
import com.ruoyi.hospital.service.HospitalTokenService;
import com.ruoyi.hospital.utils.HospitalTokenFilter;
import com.ruoyi.service.mapper.ServiceOrderotherpayMapper;
import com.ruoyi.service.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * 日程控制
 *
 * @author ZDL
 */

@RestController
@RequestMapping("/appHospital/appHospitalDate")
public class HospitalDateController {

    @Autowired
    private IServiceOrdersService serviceOrdersService;

    @Autowired
    private HospitalTokenService tokenService;

    @Autowired
    private HospitalTokenFilter hospitalTokenFilter;

    @Autowired
    private HospitalOrderService hospitalOrderService;

    @Autowired
    private HospitalCheckService hospitalCheckService;

    @Autowired
    private IServicePictureService pictureService;

    @Autowired
    private IServiceComboService comboService;

    @Autowired
    private IServicePackagesService packagesService;

    @Autowired
    private IServicePictureService servicePictureService;

    @Autowired
    private IServiceOrdernurseService ordernurseService;

    @Autowired
    private ServiceOrderotherpayMapper orderotherpayMapper;

    /**
     * 获取日程方法
     *
     * @param
     * @return 结果
     */
    @GetMapping("/getOrderList")
    public AjaxResult getOrderList(String startDate, String endDate, HttpServletRequest request) {
        try {
            if(!hospitalTokenFilter.doFilterInternal(request)) {
                AjaxResult ajaxResult = new AjaxResult();
                ajaxResult.put("code", 401);
                ajaxResult.put("msg", "用户信息过期，请重新登录");
                return ajaxResult;
            }
            LoginHospital oldHospital = tokenService.getLoginUser(request);
            if (oldHospital.getUserId() == null) {
                return AjaxResult.warn("用户信息错误");
            }

            return AjaxResult.success("获取成功");
        }catch (Exception e){
            return AjaxResult.error(e.getMessage());
        }

    }




}
